package RedisDay1;

import redis.clients.jedis.Jedis;

public class Demo1 {
    public static void main(String[] args) {
        Jedis master = null;
     try{
         //创建Jedis实例，连接Redis服务器
          master = new Jedis("192.168.111.166", 7000);
         //测试连接是否成功
         if(master.ping().equals("PONG")){
             System.out.println("连接成功");
         }
         //设置键值对
        master.set("name","小虎");
         //获取值
         String name = master.get("name");
         System.out.println("name:"+name);
     }catch (Exception e){
         e.printStackTrace();
     }finally {
         if(master!=null){
             master.close();
         }
     }
    }
}
